package com.simple.gateway.core.network;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * 项目: simple-gateway-core
 *
 * 功能描述: 基础处理器
 *
 * @author: WuChengXing
 *
 * @create: 2023-08-02 11:21
 **/
public abstract class BaseHandler<T> extends SimpleChannelInboundHandler<T> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, T msg) throws Exception {
        session(ctx, ctx.channel(), msg);
    }

    /**
     * session处理器
     *
     * @param ctx
     * @param channel
     * @param request
     */
    protected abstract void session(ChannelHandlerContext ctx, final Channel channel, T request);
}
